package com.mall.shop.service;

import com.mall.shop.entity.CompanyEntity;
import com.mall.shop.mapper.CompanyEntityMapper;
import com.mall.shop.vo.CityCompanyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyService {

    @Autowired
    CompanyEntityMapper companyEntityMapper;

    public CompanyEntity  getCompany(Integer id) {
        CompanyEntity data = companyEntityMapper.selectByPrimaryKey(id);

        return data;
    }

    public List<CompanyEntity> getCompanyList() {
        List<CompanyEntity> data = companyEntityMapper.selectAll();

        return data;
    }


    public List<CityCompanyVo> getCityCompanyList() {
        List<CityCompanyVo> data = companyEntityMapper.selectCityShop();

        return data;
    }


    public CompanyEntity insertCompany(CompanyEntity company) {
        int insertId = companyEntityMapper.insertCompany(company);

        CompanyEntity data = new CompanyEntity();
        data.setId((long) insertId);
        return data;
    }

}
